<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/COPY_jv.css" rel="stylesheet" type="text/css" />
<title>Registration with Getub</title>
<script src="validation1.5.4.1/scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="validation1.5.4.1/validation.js" type="text/javascript">
</script>
<script src="validation1.5.4.1/scriptaculous/src/effects.js" type="text/javascript"></script>
<script type="text/javascript">
 var RecaptchaOptions = {
    theme : 'clean'
 };
 </script>
</head>

<body>

<form id="registerForm" method="post" action="validtest_jv.php">
  
  <div class="back">
  <div class="footerBg">
  <div id="frame">
  <div class="header">
  <div class="topnavi">
  <ul class="topnavig">
   <li class="regbtn"><a href="#"></a></li>
   <li class="loginbtn"><a href="#"></a></li>
  </ul>
  </div><!--topnavi-->
  <a href="#"><span class="logo"></span></a><!--logo-->
  <div class="mainnavi">
  <ul class="navi">
    <li><a href="#">Home</a></li>
    <li><a href="#">Buy Books</a></li><li><a href="#">Sell Books</a></li><li><a href="#">Community</a></li><li class="li"><a href="#">About</a></li></ul>
  </div><!--mainnavi-->
  </div><!--header-->
  <div class="mainfrm">
  <div class="bluestripfrm">
  <div class="regwith"></div>
 
  
  </div><!--bluestripfrm-->
  
  <div class="formframe">
  <div class="formheading1"></div>
  
  <div class="formsection">
   <div class="formrowrg">
  <div class="fieldfrm">
  <div class="textboxfrm"><span class="label">First Name<span style="color:#FF9000">* </span></span><span class="left"></span><span class="center">
      <input class="textbox required validate-alpha" id="firstName" name="firstName" type="text" style="width:260px;"  maxlength="45" />
      </span><span class="right"></span> </div>
    </div><!--fieldfrm-->
	
  <div class="fieldfrm">
  <div class="textboxfrm"><span class="label">Last Name<span style="color:#FF9000;">* </span></span><span class="left"></span><span class="center"><input class="required" id="lastName" name="lastName" type="text" style="width:260px;"/></span><span class="right"></span></div>
  </div><!--fieldfrm-->
  
   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label">Phone</span><span class="left"></span><span class="center"><input name="phone" id="phone" type="text" class="textboxph1" width="110px" /></span><span class="right"></span>

  </div>
  </div><!--fieldfrm-->
  

  
  </div>
  

 <div class="formrowrg">
  <div class="fieldfrm">
  <div class="textboxfrm"><span class="label"><span  style="margin-left:19px;">Address</span><span style="color:#FF9000;">* </span></span><span class="left"></span><span class="center"><input class="required" id="address" name="address" type="text" style="width:260px;" /></span><span class="right"></span></div>
  
  </div><!--fieldfrm-->
 
  
   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label"><span  style="margin-left:19px;">City</span><span style="color:#FF9000;">* </span></span><span class="left"></span><span class="center"><input class="required validate-alpha" id="city" name="city" type="text" style="width:260px;" /></span><span class="right"></span></div>
  </div><!--fieldfrm-->
  
  
  
   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label"><span style="margin-left:19px;">State</span><span style="color:#FF9000;">* </span></span><span class="left"></span>
  <span class="center">
  <label>
    <select id="state" name="state" class="dropboxstate" >
<option>AL</option>
<option>AK</option>
<option>AZ</option>
<option>AR</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DE</option>
<option>FL</option>
<option>GA</option>
<option>HI</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>IA</option>
<option>KS</option>
<option>KY</option>
<option>LA</option>
<option>ME</option>
<option>MD</option>
<option selected="selected">MA</option>
<option>MI</option>
<option>MN</option>
<option>MS</option>
<option>MO</option>
<option>MT</option>
<option>NE</option>
<option>NV</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NY</option>
<option>NC</option>
<option>ND</option>
<option>OH</option>
<option>OK</option>
<option>OR</option>
<option>PA</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VT</option>
<option>VA</option>
<option>WA</option>
<option>WV</option>
<option>WI</option>
<option>WY</option>
    </select>
    </label>
  </span>
  <span class="right"></span></div>

  </div><!--fieldfrm-->
    
    <div class="fieldfrm" style="padding-left:15px;">
    	<div class="textboxzip">
  <span class="labelzip">Zip Code<span style="color:#FF9000;">*</span></span><span class="left"><span class="center">
  <input class="required validate-number textboxzip" id="zipCode" name="zipCode" type="text" style="width: 90px;" maxlength="5" /></span><span class="right"></span>
  </div>
  </div>
  </div><!-- End formrowrg right-->
 
  </div><!--end of formsection1-->
  
  <div class="formheading2"></div>
  <div class="formsection">

  <div class="formrowrg">
  <div class="fieldfrm">
  <div class="textboxfrm"><span class="label">Email<span style="color:#FF9000">* </span></span><span class="left"></span><span class="center"><input class="required validate-email" id="email" name="email" type="text" style="width:260px;" />
  </span></div>
  </div><!--fieldfrm-->
  
   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label">Confirm Email<span style="color:#FF9000">* </span></span><span class="left"></span><span class="center"><input class="other confirmEmail" name="emailConfirm" id="emailConfirm" type="text"  style="width:260px;"/></span><span class="right"></span></div>
  </div><!--fieldfrm-->
  
   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label">Your UMass<span style="color:#FF9000">* </span></span><span class="left"></span>
  <span class="center">
   <label id="university">
    <select name="university" id="university" class="dropbox required validate-selection" style="width:260px;" >
	<option selected="selected">-- Select One --</option>
    <option >UMass Amherst</option>
    <option>UMass Boston</option>
    <option>UMass Dartmouth</option>
    <option>UMass Lowell</option>
    <option>UMass Worcester Medical</option>
    </select>
    </label>
  </span>
  <span class="right"></span>
  </div>
  </div><!--fieldfrm-->
  
    </div><!--end of left col section 2-->
	
	 <div class="formrowrg">
   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label"><span  style="margin-left:19px;">Password</span><span style="color:#FF9000">* </span></span><span class="left"></span><span class="center"><input class="required validate-password" id="password" name="password" type="password" style="width:260px;"/></span><span class="right"></span></div>
  </div><!--fieldfrm-->
  

   <div class="fieldfrm">
  <div class="textboxfrm"><span class="label2">Confirm Password<span style="color:#FF9000">* </span></span><span class="center">
 <input class="other confirmPass" type="password" id="confirmPass" name="confirmPass" style="width:260px;" /></span><span class="right"></span></div>
  </div><!--fieldfrm-->
  
  
   </div><!--end of right col section 2 -->
  
  
  
  </div><!--end of formsection2-->
  <div class="formheading3"></div>
   <div class="captchaExpl"> Please fill in the two words that you see below. (click the refresh button for a new challenge) </div>
   <div class="formsection">
   <div class="capfrm">
    <script type="text/javascript"
     src="http://www.google.com/recaptcha/api/challenge?k=6LcIesESAAAAAGeEfP8_L-tw8vLDmnll-RCxx7oy">
  </script>
  <noscript>
     <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LcIesESAAAAAGeEfP8_L-tw8vLDmnll-RCxx7oy"
         height="250" width="400" frameborder="0"></iframe><br />
     <textarea name="recaptcha_challenge_field" rows="3" cols="40">
     </textarea>
     <input type="hidden" class="required" id="recaptcha_response_field" name="recaptcha_response_field" value="manual_challenge" />
  </noscript>
  
<div class="radiocheck">
<input type="checkbox" name="termsAccept" id="termsAccept" class="validate-one-required" style="width: 1.46em; height: 1.46em;" /><span style="padding-left:7px;">I accept the <a href="#">Terms of Use</a> and <a href="#">Privacy Policy</a></span></div>
   </div>
   
   <?php
	require_once('recaptchalib.php');
	$publickey = "6LcIesESAAAAAGeEfP8_L-tw8vLDmnll-RCxx7oy"; // you got this from the signup page
	echo recaptcha_get_html($publickey);
	?>
   
   <div class="submitfrm">
   <div><input type="submit" value="" name="Submit" id="submit" class="submit2" /></div>
   </div>
   </div><!--end of formsection3-->
 
  </div><!--formlftcol-->
  
  
  </div><!--mainfrm -->

   <div class="footer">
        <div class="footLeft">copyright &copy; 2011 GetUB. All rights reserved&nbsp;</div>
        <div class="footRight"><a href="#">Terms of use</a>&nbsp;|&nbsp;<a href="#">Privacy Policy</a> </div>
      </div><!--footer-->
	   </div><!--frame-->
  </div><!--footerBg-->
  </div><!--back -->
 
  <script type="text/javascript">
var valid = new Validation('registerForm', {immediate: true});
</script>
<?php include("setupMail.php"); ?>
<?php
  // check if form was submitted, or just something we show for the first time
  if (isset($_POST['firstName'])){
    // form was submitted, getting information
	$firstName = $_POST['firstName'];
	$lastName = $_POST['lastName'];
	$phone = $_POST['phone'];
	$address = $_POST['address'];
	$city = $_POST['city'];
	$state = $_POST['state'];
	$zipCode = $_POST['zipCode'];
	$email = $_POST['email'];
	$confirmEmail = $_POST['confirmEmail'];
	$university = $_POST['university'];
	$password = $_POST['password'];
	$confirmPassword = $_POST['confirmPassword'];
  	$dateRegistered = date('Y-M-d-h-m');
  
	// connection settings stored in file
	include("connectionParameters.php");
	
   $connection = mysql_connect($host,$user,$pass)
		or die ("Can't connect to server, try again later, please");

	mysql_select_db($database);
	
	
	$query = "insert into `Users`(`firstName`,`lastName`,`phone`,`address`,`city`,`state`,`zipCode`,`university`,`email`,`password`,`dateRegistered`) values ('".$firstName."','".$lastName."','".$phone."','".$address."','".$city."','".$state."','".$zipCode."','".$university."','".$email."','".$password."','".$dateRegistered."')";
	$result = mysql_query($query,$connection)
		or die ("Problem with adding information, please try again later. SQL");
	
	// info was added
	
	$query = "select UserId from Users where email='".$email."' and password='".$password."';";
	$result = mysql_query($query,$connection)
		or die ("Problem with adding information, please try again later. Email");
	
	$row = mysql_fetch_row($result);
	$userId = $row[0];
	
	$userCode = md5($email." ".$password);
	
	$query = "insert into `Activation`(`userId`,`userCode`,`activated`) values ( '".$userId."','".$userCode."','0');";
	$result = mysql_query($query,$connection)
		or die ("Problem with adding information, please try again later. Activate.");
	
	// sending message for user to activete
	$to = $email;
	$subj = "Activate your Getub.com account";
	$message = "Dear $firstName, <br />
	<p></p>
	 Thank you for registering with Getub.com!
	 In order to <b>activate</b> your account, please
	 <a href='http://getub.com/html/sample/activate.php?code=".$userCode."'> click here</a>.
	 <p></p><br />
	 If the above link doesn't work, please paste this url directly into your address bar: <br />
	 http://getub.com/html/sample/activate.php?code=".$userCode."
	<br />
	<p></p><br />
	<p></p>
	Thanks again for registering and we hope you enjoy using the site!
	<br />
	<p></p>
	- Getub Support Team
	<p></p>
	";
	$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

	$mailsend = mail($to,$subj,$message,$headers);
	
	// This should be a lighbox confirmation page
	echo "Thank you for registering with Getub! <br/>
	<p></p>
	An e-mail with an activation link has been sent to $email. Please check your inbox within 5-10 minutes to activate your account.
	<br/>
	<p></p>
	Thanks!
	<br />";
	// end lightbox message
	mysql_close($connection);
  } else {
}
?>

</form>

</body>
</html>
